<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>企业会员申请信息</title>

    <script type="text/javascript" src="{{asset('js/jquery.min.js?dd')}}"></script>
    <script type="text/javascript" src="{{asset('js/js.js?dd')}}"></script>
    <script type="text/javascript" src="{{asset('js/weblogin.js?ddd')}}"></script>

    <link rel="stylesheet" href="/css/common.css">
    <link rel="stylesheet" href="/css/weblogin/login.css">
</head>
<body>

<div class="container buy-page">
    <div class="company-apply">
        <p><span>企业名称:</span><input type="text" placeholder="请输入" id="companyName"></p>
        <p><span>企业规模:</span><input type="tel" placeholder="企业目前在职人数" id="employeeNumber"></p>
        <p><span>本人姓名:</span><input type="text" placeholder="请输入" id="userName"></p>
        <p><span>本人职务:</span><input type="text" placeholder="请输入" id="userJob"></p>
        <p><span>联系电话:</span><input type="tel" placeholder="请输入" id="userMobile"><span class="btn" disable="false" onclick="get_mobile()">获取验证码</span></p>
        <p><span>手机验证:</span><input type="tel" placeholder="请输入验证码" id="mobileCode"></p>
        <input type="hidden" id="_token" value="{{csrf_token()}}">
    </div>
    <div class="pay-btn" onclick="add_company_order()">立刻申请</div>

    <div class="description" style="margin-bottom:20px;">
        <title>会员权益</title>
        <div>
            <h3>一、老侯代读</h3>
            <p>每年50本优质书籍代读，图文、音频、视频讲解（非电子数原著）</p>
            <h3>二、商业课题分享</h3>
            <p>每年100个商业课题视频分享</p>
            <h3>三、学习365</h3>
            <p>每年365条经营智慧分享</p>
            <h3>四、资源共享</h3>
            <p>会员期间平台所有资源免费学习</p>
            <h3>五、众志共享</h3>
            <p>企业专属线上众智共享自学习社群</p>
            <h3>六、内部培训</h3>
            <p>企业内部学习官培养</p>
            <h3>七、落地辅导</h3>
            <p>专属学习官上门培训落地辅导</p>
        </div>
    </div>
</div>
</body>
</html>

<script>

    var timer = "";
    function get_mobile()
    {
        var disable = $('.btn').attr('disable');
            if(disable == 'true')
            {
                alert('发送中,请稍等');
                return ;
            }
        var mobile  = $('#userMobile').val();
        var pattern = /^1\d{10}$/;
        if(!pattern.test(mobile))
        {
            alert("请检查手机号");
            return ;
        }

        //获取验证码
        var url = "/mobile/getCode?mobile="+mobile;
        $.ajax(url).success(function(res){

            if(res.code != 200)
            {
                alert(res.message);
                return false;
            }
            $('.btn').attr('disable','true').data('time',120);
            timer = setInterval(function()
            {
                var btn = $('.btn');
                var time = parseInt(btn.data('time')) - 1;

                if(time == 0)
                {
                    clearInterval(timer);
                    btn.data('time',120).text('获取验证码');

                }else{

                    btn.text("已发送（"+ time + "）").data('time',time);
                }
            },1000);
        });
    }



    function add_company_order()
    {
        var data    = {};
        $('.company-apply input').each(function()
        {
            var ele     = $(this);
            var atr     = ele.attr('id');
            data[atr]   = ele.val();
        });

        var pattern = /^1\d{10}$/;
        if(!pattern.test(data['userMobile']))
        {
            alert("请检查手机号");
            return ;
        }
        //检查验证码
        var url = "/mobile/checkCode?mobile="+data.userMobile+"&code="+data.mobileCode;
        $.get(url).success(function(res)
        {
            if(res.data.valid == 0)
            {
                alert('请检查验证码和手机号');
                return ;
            }
            $.ajax({
                url:'/web/weblogin/company_apply',
                data:data,
                type:'post'
            }).success(function(res){
                alert(res.message);
                setTimeout(function(){
                    location.href = "/downloadpage.html";
                },1000);
            });
        })
    }


</script>